package model;

import java.util.Collection;
import java.util.List;

public abstract class Seed {

	public abstract int getHeight();

	public abstract int getLength();

	public abstract List<Cell> getCells();
	
	protected void linkCells(Collection<Cell> cells) { //This is a very inefficient algorithm
		Collection<Cell> cellsAux = cells;
		for (Cell cell : cells) {
			for (Cell cellAux : cellsAux) {
				bondIfApropiate(cell,cellAux);
			}
		}
	}	
	protected void bondIfApropiate(Cell cell, Cell cellAux) { 
		int auxX = cellAux.getX();
		int auxY = cellAux.getY();
		int x = cell.getX();
		int y = cell.getY();
		if ((x-1 <= auxX && auxX <= x+1) && (y-1 <= auxY && auxY <= y+1) && (cell != cellAux)){
			cell.addNeighbour(cellAux);
		}
	}

}
